import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";

const pathResolve = (dir: string): any => {
  return resolve(process.cwd(), ".", dir);
};
const alias: Record<string, string> = {
  "@": pathResolve("src"),
  assets: pathResolve("./src/assets"),
  "~bootstrap": "bootstrap"
};

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: { alias },
  server: {
    port: 4002,
    open: true,
    proxy: {
      "/api": {
        target: "http://127.0.0.1:3000"
      }
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/styles/variables";`,
        silenceDeprecations: [
          "import",
          // "mixed-decls",
          "color-functions",
          "global-builtin"
        ]
      }
    }
  },
  build: {
    sourcemap: false,
    outDir: "dist",
    emptyOutDir: true,
    chunkSizeWarningLimit: 1500
  }
});
